package com.hz.web.util;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import com.hz.web.dao.ManyDemoDao;

@Aspect
@Component
public class MultipleDataSourceAspectAdvice {

	  	@Around("execution(public * com.hz.web.dao.*.*(..))")
	    public Object doAround(ProceedingJoinPoint jp) throws Throwable {
	        if (jp.getTarget() instanceof ManyDemoDao) {
	            MultipleDataSource.setDataSourceKey("dataSourceFrom");
	        } else {
	            MultipleDataSource.setDataSourceKey("dataSource1");
	        }
	        return jp.proceed();
	    }
}
